﻿using System.Drawing;
using System.Windows.Forms;

namespace 云起停车_岗亭端
{
    public partial class Loading : Form
    {
        public Loading()
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;
            TopMost = true;
            ShowInTaskbar = false;
            FormBorderStyle = FormBorderStyle.None;
            BackColor = Color.White;
            TransparencyKey = Color.White;

        }

        /// <summary>
        /// 关闭命令
        /// </summary>
        public void closeOrder()
        {
            if (InvokeRequired)
            {
                //这里利用委托进行窗体的操作，避免跨线程调用时抛异常，后面给出具体定义
                CONSTANTDEFINE.SetUISomeInfo UIinfo = () =>
                {
                    while (!IsHandleCreated)
                    {
                        ;
                    }

                    if (IsDisposed)
                    {
                        return;
                    }

                    if (!IsDisposed)
                    {
                        Dispose();
                    }
                };
                Invoke(UIinfo);
            }
            else
            {
                if (IsDisposed)
                {
                    return;
                }

                if (!IsDisposed)
                {
                    Dispose();
                }
            }
        }

        private void LoadingForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!IsDisposed)
            {
                Dispose(true);
            }
        }

        internal class CONSTANTDEFINE
        {
            public delegate void SetUISomeInfo();
        }
    }
}
